package bComponent
{
	import mx.containers.Form;
	import mx.core.Container;
	import mx.core.IVisualElementContainer;

	public class Custom_Form extends Form
	{
		public function Custom_Form()
		{
			super();
		}
		
		
		public function reset():void
		{
			
		}
		
		public function validate():Boolean
		{
			var childs:Array=this.getChildren();
			if(_validate(childs)=="true")
			{
				return true;
			}
			else
			{
				return false;
			}

		}
		
		
		private function _validate(childs:Array):String
		{
			var b:String="true";
			for(var i:Number=0;i<childs.length;i++)
			{
				if(childs[i] is Custom_HGroup_Comp)
				{
					//trace(childs[i]);
					if(childs[i].validate()==false)
					{
						b="false";
					}
				}
				else
				{
					if(childs[i] is IVisualElementContainer)
					{
						b= _validate(getChildrenArray(childs[i]));
					}
				}
				if(b=="false")
				{
					break;
				}
			}
			return b;
		}
		
		private function getChildrenArray(c:IVisualElementContainer):Array
		{
			var ary:Array=[];
			for(var i:Number=0;i<c.numElements;i++)
			{
				ary.push(c.getElementAt(i));
			}
			return ary;
		}
		
	}
}